<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<ui:composition template="/pages/template/system_template.xhtml">
	<ui:define name="content">
		<div class="div-content">

			<p:growl autoUpdate="true" showDetail="true" showSummary="true"
				life="10000" />

			<div align="center" class="header-title-page">
				Funcionários
				<p:separator />
			</div>

			<h:form id="frmRemoteCommand">
				<p:remoteCommand name="onloadTabela"
					actionListener="#{funcionarioManagedBean.carregarTabela}"
					autoRun="true" update=":frmFuncDataTable:funcionarioDataTable" />
			</h:form>

			<h:form id="frmFuncDataTable">
				<p:dataTable id="funcionarioDataTable" rows="5"
					rowsPerPageTemplate="5,10,15" paginator="true"
					emptyMessage="Não há registros."
					value="#{funcionarioManagedBean.listaFuncionarios}" var="func"
					paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">

					<p:column headerText="Matrícula">
						<h:outputText value="#{func.matricula}" />
					</p:column>

					<p:column headerText="Nome">
						<h:outputText value="#{func.nome}" />
					</p:column>

					<p:column headerText="Função">
						<h:outputText value="#{func.funcao}" />
					</p:column>

					<p:column headerText="E-mail">
						<h:outputText value="#{func.email}" />
					</p:column>

					<p:column headerText="Perfil">
						<h:outputText value="#{func.descricao}" />
					</p:column>

					<p:column headerText="Usuário">
						<h:outputText value="#{func.usuario}" />
					</p:column>

					<p:column headerText="Status">
						<h:outputText value="#{func.status}" />
					</p:column>

					<p:column headerText="Ações" styleClass="centralizar">
						<p:commandButton id="btnEdit" title="Editar" icon="ui-icon-wrench"
							style="width:22px; height:22px;"
							actionListener="#{funcionarioManagedBean.carregarPerfil}"
							oncomplete="dialogEditFuncionario.show()"
							update=":idDialogEditFuncionario">
							<f:setPropertyActionListener
								target="#{funcionarioManagedBean.funcionarioSelecionado}"
								value="#{func}" />
						</p:commandButton>

						<p:commandButton id="btnIna" title="Inativar" icon="ui-icon-power"
							style="width:22px; height:22px;"
							oncomplete="dialogInativarFuncionario.show()"
							update=":idDialogInativarFuncionario">
							<f:setPropertyActionListener
								target="#{funcionarioManagedBean.funcionarioSelecionado}"
								value="#{func}" />
						</p:commandButton>
					</p:column>
				</p:dataTable>

				<p:commandButton value="Adicionar funcionário"
					style="margin-top: 10px;"
					actionListener="#{funcionarioManagedBean.carregarPerfil}"
					oncomplete="dialogCadFuncionario.show()"
					update=":idDialogCadFuncionario" />

			</h:form>

			<ui:include
				src="/pages/system/dialog/dialog_cadastrar_funcionario.xhtml" />

			<ui:include
				src="/pages/system/dialog/dialog_editar_funcionario.xhtml" />

			<ui:include
				src="/pages/system/dialog/dialog_inativar_funcionario.xhtml" />

		</div>
	</ui:define>
</ui:composition>

</html>